{smcl}
{com}{sf}{ul off}{txt}{.-}
      name:  {res}<unnamed>
       {txt}log:  {res}C:\Users\vgonz\Dropbox\Pitt\OneDrive for Business\Dissertation - Vale\Paper 2 - Political-Economic Polarization\Replication\Log\1_3_Switching_Appendix_SpoonKluver.smcl
  {txt}log type:  {res}smcl
 {txt}opened on:  {res}29 Aug 2024, 15:37:36

{com}. do "C:\Users\vgonz\Dropbox\Pitt\OneDrive for Business\Dissertation - Vale\Paper 2 - Political-Economic Polarization\Replication\Do\1_3_Switching_Appendix_SpoonKluver.do"
{txt}
{com}. *****************************************************************************
. *    Table Additional Context Spoon & Kluever's replication data                *
. *                                                                                                                                                       *                       
. * Author:                       Valentina Gonzalez Rostani                                                      *
. * Contact:                      mag384@pitt.edu                                                                 *
. * Date:                         August 9 2024                                                                                   *
. * Version:                      Stata 17                                                                                                *                                                                          
. *                                                                                                                                                       *
. *****************************************************************************
. /*
> This do-file:
> - Creates Table A10 using data from Spoon & Kluever's replication data (EJPR, 2019). 
> 
> Input:
> - Data\SpoonKluever_2019_EJPR_PartyConvergence.dta
> 
> Output:
> - Table A10: Switching in Germany from mainstream to non-mainstream parties 2002-2013
> 
> */
. 
. *Defining Directory
. cd "C:\Users\vgonz\Dropbox\Pitt\OneDrive for Business\Dissertation - Vale\Paper 2 - Political-Economic Polarization\Replication"
{res}C:\Users\vgonz\Dropbox\Pitt\OneDrive for Business\Dissertation - Vale\Paper 2 - Political-Economic Polarization\Replication
{txt}
{com}. 
. *##########################################
. * Load data
. *##########################################
. {c -(}
. *Calling the data
. use "Data\SpoonKluever_2019_EJPR_PartyConvergence.dta", clear 
{txt}(Spoon/Klüver (2019) EJPR: Party covergence and vote switching)
{com}. {c )-}
{txt}
{com}. *******************************************************************************
. * Preparing variables
. *******************************************************************************
. {c -(}
. * Election years
. gen year = 2002 in 1
{txt}(14,633 missing values generated)
{com}. replace year = 2005 in 2
{txt}(1 real change made)
{com}. replace year = 2009 in 3
{txt}(1 real change made)
{com}. replace year = 2013 in 4
{txt}(1 real change made)
{com}. 
. * Initialize variables
. gen SPD = .
{txt}(14,634 missing values generated)
{com}. gen Liberal = .
{txt}(14,634 missing values generated)
{com}. gen CDU = .
{txt}(14,634 missing values generated)
{com}. gen Total_Switching = .
{txt}(14,634 missing values generated)
{com}. 
. * Election dates and party codes
. local dates "22sep2002 18sep2005 27sep2009 22sep2013"
. local SPD 41320
. local Liberal 41420
. local CDU 41521
. 
. * Loop over each date
. local i = 1
. foreach date of local dates {c -(}
{txt}  2{com}.     * Total Switching for the date
.     quietly summarize switch_main if country == 41 & edate == date("`date'", "DMY")
{txt}  3{com}.     replace Total_Switching = r(mean) * 100 in `i'
{txt}  4{com}. 
.     * SPD
.     quietly summarize switch_main if country == 41 & edate == date("`date'", "DMY") & party_last == `SPD'
{txt}  5{com}.     replace SPD = r(mean) * 100 in `i'
{txt}  6{com}. 
.     * Liberal
.     quietly summarize switch_main if country == 41 & edate == date("`date'", "DMY") & party_last == `Liberal'
{txt}  7{com}.     replace Liberal = r(mean) * 100 in `i'
{txt}  8{com}. 
.     * CDU
.     quietly summarize switch_main if country == 41 & edate == date("`date'", "DMY") & party_last == `CDU'
{txt}  9{com}.     replace CDU = r(mean) * 100 in `i'
{txt} 10{com}. 
.     local i = `i' + 1
{txt} 11{com}. {c )-}
{txt}(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
(1 real change made)
{com}. {c )-}
{txt}
{com}. // table A10: Switching in Germany from mainstream to non-mainstream parties 2002-2009
. {c -(}
. * Format the variables to display one decimal place
. format SPD Liberal CDU Total_Switching %4.1f
. 
. 
. * Use tabdisp to display the results in a tabular format
. tabdisp year, c(SPD Liberal CDU Total_Switching)

{txt}{hline 10}{c TT}{hline 67}
     year {c |}             SPD          Liberal              CDU  Total_Switching
{hline 10}{c +}{hline 67}
     2002 {c |}            {res}10.6             12.0              1.5              7.1
     {txt}2005 {c |}             {res}0.4              8.1              4.1              5.0
     {txt}2009 {c |}             {res}1.9              9.1              0.9              3.8
     {txt}2013 {c |}             {res}9.8             22.2              3.1              6.7
        {txt}. {c |}                {res}                                                   
{txt}{hline 10}{c BT}{hline 67}
{com}. {c )-}
{txt}
{com}. 
{txt}end of do-file

{com}. exit, clear
